package com.zmj.sy.mom.srv.aps.controller;

import com.zmj.sy.mom.srv.aps.bean.vo.base.*;
import com.zmj.sy.mom.srv.aps.bean.vo.phase.*;
import com.zmj.sy.mom.srv.aps.service.PhaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RequiredArgsConstructor
@Api(tags = "工序")
@RestController
@RequestMapping("/phase")
public class PhaseController {

    private final PhaseService phaseService;

    @ApiOperation("列表")
    @GetMapping("/list")
    public BasePageResVo<PhaseListResVo> list(PhaseListReqVo reqVo) {
        return phaseService.list(reqVo);
    }

    @ApiOperation("添加")
    @PostMapping("/add")
    public BaseResVo add(@RequestBody PhaseAddReqVo reqVo) {
        phaseService.add(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("编辑")
    @PostMapping("/edit")
    public BaseResVo edit(@RequestBody PhaseEditReqVo reqVo) {
        phaseService.edit(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("删除")
    @PostMapping("/delete")
    public BaseResVo delete(BaseIdReqVo reqVo) {
        phaseService.delete(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("下拉框")
    @GetMapping("/select")
    public BaseSelectResVo select(PhaseSelectReqVo reqVo) {
        return BaseSelectResVo.of(phaseService.select(reqVo));
    }

    @ApiOperation("列表")
    @GetMapping("/listAll")
    public BaseListResVo<PhaseListResVo> listAll(PhaseListReqVo reqVo) {
        return phaseService.listAll(reqVo);
    }
}
